from kano.wand import Wand,PATTERN
import sys

def main():
    # If we pass a -d flag, enable debugging
    debug = False
    if len(sys.argv) > 1:
        debug = sys.argv[1] == "-d"

    # Create a new wand scanner
    wand = Wand(debug=debug)
    try:
        # While we don't have any wands
        while not wand.connected:
            # Scan for wands and automatically connect
            print("Scanning...")
            wand.connect()

    # Detect keyboard interrupt and disconnect wands
    except KeyboardInterrupt as e:
        print(e)

if __name__ == "__main__":
    main()
